package com.itheima.maipiao.maipiao;

import java.util.concurrent.atomic.AtomicInteger;

public class Ticket extends Thread {
    private static volatile AtomicInteger count=new AtomicInteger(100);
private static Object object= new Object();
    @Override
    public void run() {
        while(true){
                if(count.get()<=0){
                    break;
                }else {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    count.decrementAndGet();
                    System.out.println(Thread.currentThread().getName()+"正在卖票,还剩"+count);
                }


        }
    }


}
